package com.yc.system.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.system.entity.BookOrder;
import com.yc.system.entity.BookTv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.system.vo.TvInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 公告 Mapper 接口
 * </p>
 *
 * @author 1850140986@qq.com
 * @since 2022-12-03
 */
@Mapper
public interface BookTvMapper extends BaseMapper<BookTv> {
    @Select("Select tv.*,user.username,user.user_id from t_book_tv tv join t_user user on user.user_id=tv.user_id where tv.deleted=0 ")
    List<TvInfo> getBooksByPageRandom(IPage<BookOrder> page, int userId);

    @Update("update t_book_tv set deleted=1 where tv_id=#{tvId}")
    int deleteByTvId(Integer tvId);
    @Update("update t_book_tv set tv_title=#{tvTitle},message=#{message},tv_type=#{tvType} where tv_id=#{tvId}")
    int updateByTvId(TvInfo tv);

    @Insert("insert into t_book_tv (user_id,tv_title,message,tv_type) values (#{userId},#{tvTitle},#{message},#{tvType})")
    int add(TvInfo tv);
}
